﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    static int Time = 61;
    static int score = 0;
    static int Result = 0;        
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Time = 61;
            FunctionLoad();
        }
        Label2.Text = "Time Left: ";
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        Time = Time - 1;
        Label1.Text = Time.ToString();
        if (Time == 0)
        {
            Response.Redirect("HomePage.aspx");
        }
    }
    protected void Button1_Click1(object sender, EventArgs e)
    {
        if(Tbx_Answer.Text == Result.ToString())
        {
            score=score+10;            
        }
        Label3.Text = "Your Score: ";
        Label4.Text = score.ToString();
        FunctionLoad();
        
    }
    public void FunctionLoad()
    {        
        Random Number1 = new Random();
        int a = Number1.Next(1, 21);
        int b = Number1.Next(1, 21);
        Lbl_Problem.Text = "Q. Solve ";
        int Operation = Number1.Next(1, 4);
        char Symbol = '+';        
        switch (Operation)
        {
            case 1:
                {
                    Symbol = '+';
                    Result = a + b;
                } break;
            case 2:
                {
                    Symbol = '-';
                    Result = a - b;
                } break;
            case 3:
                {
                    Symbol = '*';
                    Result = a * b;
                } break;
            case 4:
                {
                    Symbol = '/';
                    Result = (a / b);
                } break;
        }
        Lbl_Problem.Text = Lbl_Problem.Text + a.ToString() + " " + Symbol + " " + b.ToString();
        Tbx_Answer.Text = "";
    }
    static int click = 1;
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        click += 1;
        if (click % 2 == 0)
            TextBox1.Visible = true;
        else
            TextBox1.Visible = false;
    }
}